home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gwu / help.c < prev    next >
C/C++ Source or Header  |  1996-01-30  |  7KB  |  299 lines

  1. /*
  2.     GWAda Development Environment for 386/486 PCs   
  3.     Copyright (C) 1993, Arthur Vargas Lopes  & Michael Bliss Feldman
  4.                         vlopes@vortex.ufrgs.br mfeldman@seas.gwu.edu
  5.  
  6.     This program is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation; version 2 of the License.    
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. #include "externs.h"
  21.                 
  22. void AVL_HELP(char *local)
  23. {
  24.     AVL_LINE_PTR head = NULL, temp;
  25.     int x ;
  26.     char s[100];
  27.     int no = 0;
  28.     int ch, save_w;
  29.     FILE *fp, *fopen();
  30.     AVL_WIN_PTR hw;
  31.     AVL_EDIT_WINDOW_PTR w;
  32.     char c;
  33.     int updt = 1;
  34.     short r1, r2, c1, c2, i, j;
  35.     extern int avl_ctrl_c;
  36.     AVL_LINE_PTR saved;
  37.     short old_bk_color, old_color;
  38.     short old_sta_bk_color, old_sta_color;
  39.     char *pl;
  40.     pl = getenv("ADAED");
  41.     if (pl == NULL)
  42.         pl=getenv("adaed");
  43.     if (pl != NULL)  
  44.         sprintf(s,"%s%c%s",pl,'\\',local);
  45.     else  {
  46.         AVL_ERROR("Set the ADAED environment variable first (see readme.gw).");
  47.         return;
  48.         }        
  49.     save_w = avl_window;
  50.     w = &avl_windows[avl_window=AVL_MAX_WINDOWS];
  51.     hw = AVL_MAKE_WINDOW("",1,1,24,80,7,15);
  52.     _settextrows( 25 );
  53.     _clearscreen( _GCLEARSCREEN );
  54.     w -> head = w -> current_line = NULL;
  55.     AVL_LOAD_FILE(s);
  56.     temp = head;
  57.     while ( 1 )   {  /*  Command mode  */
  58.         ch = getch();
  59.         switch( ch )  {
  60.             case  1  : /* Ctrl-Left == Ctrl-A */ AVL_WORD_BACKWARD(); break;
  61.             case  6  : /* Ctrl-Right == Ctrl-F */ AVL_WORD_FORWARD(); break;
  62.             case  4  : /* Ctrl-D == Right */  AVL_CURSOR_RIGHT(1); break;
  63.             case 14  :  /*  Ctrl-N */
  64.             case 13  :  /*  Enter  */  AVL_CURSOR_DOWN(1); break;
  65.             /*  Control keys */
  66.             case 11 : /* Mark Block - Ctrl K */
  67.                 ch = toupper(getch());
  68.                 if (ch == 'B' || ch == 'K') {
  69.                     AVL_GUIDE_MBLOCK ();
  70.                     break;
  71.                     }
  72.                 else if (ch == 'C')  {
  73.                     AVL_PROCESS_COPY();
  74.                     break;
  75.                     }
  76.                 else if (ch == 'S')  {
  77.                     AVL_SAVE();
  78.                     break;
  79.                     }
  80.                 if (ch == 0) ch = getch();
  81.                 AVL_ERROR("Use only Ctrl-k b, Ctrl-k k, Ctrl-k c and Crtl-k s");
  82.                 break;
  83.             case 17 : /* Go to begin/end of text file  Ctrl-Q R or C or Y */
  84.                 avl_ctrl_c = 0;
  85.                 ch = toupper(getch());
  86.                 if (ch == 89 || ch == 25)   {  /* Got a Ctrl-Q Y */
  87.                     w -> current_line -> line [w -> txt_col] = '\0';
  88.                     AVL_UPDATE_LINE();
  89.                     break;
  90.                     }
  91.                 AVL_UPDATE_LINE();
  92.                 if (ch == 'C' || avl_ctrl_c) {
  93.                     if (w -> head -> previous != w -> head)
  94.                         AVL_DO_GOTO(w -> head -> previous -> line_no);
  95.                     break;
  96.                     }
  97.                 else if (ch == 'R' || ch == 18) {
  98.                     avl_ctrl_c = 0;
  99.                     if (w -> head -> next != w -> head)
  100.                         AVL_DO_GOTO(w -> head -> next -> line_no);
  101.                     break;
  102.                     }
  103.                 if (ch == 0) ch = getch();
  104.                 AVL_ERROR("Use only Ctrl-q r, Ctrl-q c or Ctrl-q y");
  105.                 break;
  106.             case 27  :  /*  ESC       */  
  107.                    AVL_FREE_ALL();
  108.                    avl_window = save_w;
  109.                 sprintf(avl_message," ");
  110.                    AVL_DEL_WINDOW(hw);
  111.                    return;
  112.             case  0  : {
  113.                 ch = getch();
  114.                 switch( ch ) {
  115.                     /*  Alt keys  */
  116.                     case 59 : /* F1 without alternate   */ AVL_HOT_KEYS(); break;
  117.                     case 35 : /* Help */ AVL_ENVIRONMENT('H'); break;
  118.                     case 107: /* Alt-F4   */ AVL_EXIT(); return;
  119.                     case 63 : /* F5   */ AVL_GOTO(); break;    
  120.                     case 71 : /* Home */ AVL_CURSOR_HOME(); break;
  121.                     case 79 : /* End  */ AVL_CURSOR_END(); break;
  122.                     case 73 : /* PgUp */ AVL_CURSOR_PGUP(); break;
  123.                     case 81 : /* PgDn */ AVL_CURSOR_PGDN(); break;
  124.                     case 75 : /* Left */ AVL_CURSOR_LEFT(no); no = 0; break;
  125.                     case 77 : /* Right*/ AVL_CURSOR_RIGHT(no); no = 0; break;
  126.                     case 72 : /* Up   */ AVL_CURSOR_UP  (no); no = 0; break;
  127.                     case 80 : /* Down */ AVL_CURSOR_DOWN(no); no = 0; break;
  128.                     case 92 : /* Shift+F9 == Alt-F D */ AVL_DOS_CMD(); break;
  129.                     case 115 : /* Ctrl-Left == Ctrl-A */ AVL_WORD_BACKWARD(); break;
  130.                     case 116 : /* Ctrl-Right == Ctrl-F */ AVL_WORD_FORWARD(); break;
  131.                     case 117 : /* Ctrl-End */
  132.                         AVL_DO_GOTO(w -> head -> previous -> line_no);
  133.                         break;
  134.                     case 119 : /* Ctrl-Home */
  135.                         AVL_DO_GOTO(w -> head -> next -> line_no);
  136.                         break;
  137.                     default : putchar(7); break;
  138.                     }
  139.                 break;
  140.                 }
  141.             default : {
  142.                 putchar(7);
  143.                 break;
  144.                 }               
  145.             }
  146.  
  147.         }
  148. }
  149.  
  150.  
  151.  
  152.  
  153. void AVL_HELP_INTRO()
  154. {
  155.     AVL_HELP("lrm-01.hlp");
  156. }
  157.    
  158. void AVL_HELP_LEXIE()
  159. {
  160.     AVL_HELP("lrm-02.hlp");
  161. }
  162.    
  163. void AVL_HELP_DCLTY()
  164. {
  165.     AVL_HELP("lrm-03.hlp");
  166. }
  167.    
  168. void AVL_HELP_NEXPS()
  169. {
  170.     AVL_HELP("lrm-04.hlp");
  171. }
  172.    
  173. void AVL_HELP_STMTS()
  174. {
  175.     AVL_HELP("lrm-05.hlp");
  176. }
  177.    
  178. void AVL_HELP_SUBPG()
  179. {
  180.     AVL_HELP("lrm-06.hlp");
  181. }
  182.    
  183. void AVL_HELP_PACKS()
  184. {
  185.     AVL_HELP("lrm-07.hlp");
  186. }
  187.    
  188. void AVL_HELP_VRULE()
  189. {
  190.     AVL_HELP("lrm-08.hlp");
  191. }
  192.    
  193. void AVL_HELP_TASKS()
  194. {
  195.     AVL_HELP("lrm-09.hlp");
  196. }
  197.    
  198. void AVL_HELP_PSCIS()
  199. {
  200.     AVL_HELP("lrm-10.hlp");
  201. }
  202.    
  203. void AVL_HELP_EXCEP()
  204. {
  205.     AVL_HELP("lrm-11.hlp");
  206. }
  207.    
  208. void AVL_HELP_GENER()
  209. {
  210.     AVL_HELP("lrm-12.hlp");
  211. }
  212.    
  213. void AVL_HELP_RCIDF()
  214. {
  215.     AVL_HELP("lrm-13.hlp");
  216. }
  217.    
  218. void AVL_HELP_INOUT()
  219. {
  220.     AVL_HELP("lrm-14.hlp");
  221. }
  222.    
  223. void AVL_HELP_ANEXA()
  224. {
  225.     AVL_HELP("lrm-a.hlp");
  226. }
  227.    
  228. void AVL_HELP_ANEXB()
  229. {
  230.     AVL_HELP("lrm-b.hlp");
  231. }
  232.    
  233. void AVL_HELP_ANEXC()
  234. {
  235.     AVL_HELP("lrm-c.hlp");
  236. }
  237.    
  238. void AVL_HELP_ANEXD()
  239. {
  240.     AVL_HELP("lrm-d.hlp");
  241. }
  242.    
  243. void AVL_HELP_ANEXE()
  244. {
  245.     AVL_HELP("lrm-e.hlp");
  246. }
  247.    
  248. void AVL_HELP_ANEXF()
  249. {
  250.     AVL_HELP("lrm-f.hlp");
  251. }
  252.    
  253.  
  254.  
  255. void AVL_HELP_EDITOR()
  256. {
  257.     AVL_HELP("AVL_EDIT.HLP");
  258. }
  259.  
  260. void AVL_HELP_OPTIONS()
  261. {
  262.     AVL_HELP("AVL_OPTI.HLP");
  263. }
  264.  
  265. void AVL_HELP_FILE()
  266. {
  267.     AVL_HELP("AVL_FILE.HLP");
  268. }
  269.  
  270. void AVL_HELP_BIND()
  271. {
  272.     AVL_HELP("AVL_BIND.HLP");
  273. }
  274.  
  275. void AVL_HELP_GWADA()
  276. {
  277.     AVL_HELP("AVL_GWAD.HLP");
  278. }
  279.  
  280. void AVL_HELP_COMPILER()
  281. {
  282.     AVL_HELP("AVL_COMP.HLP");
  283. }
  284.  
  285. void AVL_HELP_INTERPRETER()
  286. {
  287.     AVL_HELP("AVL_INTE.HLP");
  288. }
  289.  
  290. void AVL_HELP_WINDOW()
  291. {
  292.     AVL_HELP("AVL_WIND.HLP");
  293. }
  294.  
  295. void AVL_MDH_TOOLS()
  296. {
  297.     AVL_HELP("AVL_MDHE.HLP");
  298. }
  299.